load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "backuppb_proto",
    srcs = ["backup.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/build:build_proto",
        "//pkg/cloud/cloudpb:cloudpb_proto",
        "//pkg/multitenant/mtinfopb:mtinfopb_proto",
        "//pkg/roachpb:roachpb_proto",
        "//pkg/sql/catalog/descpb:descpb_proto",
        "//pkg/sql/stats:stats_proto",
        "//pkg/util/hlc:hlc_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "backuppb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/ccl/backupccl/backuppb",
    proto = ":backuppb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/build",
        "//pkg/cloud/cloudpb",
        "//pkg/multitenant/mtinfopb",
        "//pkg/roachpb",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/execinfrapb",  # keep
        "//pkg/sql/stats",
        "//pkg/util/hlc",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_library(
    name = "backuppb",
    srcs = ["backup.go"],
    embed = [":backuppb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/ccl/backupccl/backuppb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/cloud",
        "//pkg/jobs",
        "//pkg/jobs/jobspb",
        "//pkg/multitenant/mtinfopb",
        "//pkg/sql/parser",
        "//pkg/sql/protoreflect",
        "//pkg/sql/sem/tree",
        "//pkg/util/bulk",
        "//pkg/util/hlc",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_gogo_protobuf//jsonpb",
        "@com_github_gogo_protobuf//proto",
        "@io_opentelemetry_go_otel//attribute",
    ],
)

go_test(
    name = "backuppb_test",
    srcs = ["backup_test.go"],
    deps = [
        ":backuppb",
        "//pkg/multitenant/mtinfopb",
        "@com_github_stretchr_testify//require",
    ],
)
